package logic

import (
	"context"
	"meituan-waimai/models/mysql"

	"meituan-waimai/meituanrpc/internal/svc"
	"meituan-waimai/meituanrpc/meituanrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderEvaluateListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewOrderEvaluateListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderEvaluateListLogic {
	return &OrderEvaluateListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *OrderEvaluateListLogic) OrderEvaluateList(in *meituanrpc.OrderEvaluateListRequest) (*meituanrpc.OrderEvaluateListResponse, error) {
	// todo: add your logic here and delete this line
	var list mysql.OrderEvaluate
	mysql.DB.Where("user_id = ? AND order_id = ?", in.UserId, in.OrderId).Find(&list)
	return &meituanrpc.OrderEvaluateListResponse{
		UserId:  list.UserId,
		OrderId: list.OrderId,
		Content: list.Content,
		Star:    int64(list.Star),
		Target:  int64(list.Target),
	}, nil
}
